Tables

T3.0 contains generalized hash tables. A table associates a key with a value. make-hash-table is the most general way to make a hash table. In addition, the most common types of tables have been predefined.


$\textstyle \parbox{.75in}{\sc Note:}$ $\textstyle \parbox{\notewidth}{\em Tables should be used in place of property lists.}$


(make-hash-table type? hash comparator gc? id) $\Longrightarrow$ table procedure

make-hash-table creates a table which associates keys to values. Any object may be a key or a value.

type?
— is a predicate. All keys in the table must answer true to the predicate type?.

hash
— is a procedure from keys to fixnums which is used to hash the table entries.

comparator
— is an equality predicate on keys.

gc?
— is a boolean value which specifies whether the hash procedure is dependent on the memory location(s) occupied by the object, i.e. whether or not the table must be rehashed after a garbage collection.

id
— is an identifier used by the print method of the table.


(hash-table? object) $\Longrightarrow$ boolean predicate

boolean

hash-table returns true if the object is a hash table.


(table-entry table key) $\Longrightarrow$ object settable

table-entry returns the object associated with the key in the table if there is an entry for key, otherwise returns false.


(walk-table proc table) $\Longrightarrow$ undefined procedure

walk-table invokes procedure, a procedure of two arguments, on each key, value association in the table. Note that it is an error to perform any operations on the table while walking it.

The following common table types have been predefined as follows:


(make-table . id) $\Longrightarrow$ table procedure

make-table creates a table in which any object can be a key and eqv? is used as the equality predicate on keys.


(table? object) $\Longrightarrow$ boolean procedure

table? returns true if the object is an eq? table.


(make-string-table . id) $\Longrightarrow$ table procedure

make-string-table creates a table in which the keys must be strings and string-equal? is used as the equality predicate on keys.


(string-table? object) $\Longrightarrow$ boolean procedure

string-table? returns true if the object is a string-table.


(make-symbol-table . id) $\Longrightarrow$ symbol-table procedure

make-symbol-table creates a table in which the keys must be symbols and eq? is used as the equality predicate on keys.


(symbol-table? object) $\Longrightarrow$ boolean procedure

symbol-table? returns true if the object is a symbol-table.